<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <meta name="csrf_token" id="token" content="{{ csrf_token() }}">
    @include('public.h5_head')
    <title>待收货订单</title>
    <script src="{{ env('CDN_DOMAIN_NAME') }}/js/commonjs/rem.js"></script>
    <link rel="stylesheet" type="text/css" href="{{ env('CDN_DOMAIN_NAME') }}/css/commoncss/common.css"/>
    <link rel="stylesheet" type="text/css" href="{{ env('CDN_DOMAIN_NAME') }}/css/due.css"/>
    <style>
        .pay_mask{width:100%;height:100%;position:absolute;top:0;left:0;z-index:1000;background:#000;}
        .pay_mask2{opacity:0.4;filter:alpha(opacity=40)}

        .pay_over{width:11.52rem;min-height:4.48rem;text-align:center;color:#383838;background:#F7F7F7;-moz-border-radius: 0.555rem;-webkit-border-radius: 0.555rem;border-radius: 0.555rem;font-size:0.725rem;position: absolute;top:10rem;left:2.24rem;z-index:2000;}
        .pay_over .pay_pass{padding-bottom: 1rem;min-height:2.56rem;line-height:2.56rem;border-bottom:1px solid #ccc;box-sizing:border-box;}
        .pay_over .pay_ok{height:1.92rem;line-height:1.92rem;color:#3A79FF;}

        .pay_over .pay_pass p{font-size:0.725rem;margin-bottom:0.2rem;width:100%;height:1rem;}
        .pay_over .pay_pass p span{margin-right:0.5rem;}
    </style>
</head>
<script src="{{ env('CDN_DOMAIN_NAME') }}/js/commonjs/iscroll.js"></script>
<script src="{{ env('CDN_DOMAIN_NAME') }}/js/app.js"></script>
<body onload="loaded()">
<div id="box_due">
    <div class="wrap">
        <div class="main_due">
            <div class="seek" onclick="window.location.href='/user/selectOrders'">
                <div class="seek_img">
                    <img class="seek_pic" src="/img/seek.png" alt="">
                    <p class="seek_name">搜索</p>
                </div>
            </div>
            @if(count($datas) == 0)
            <div class="main_empty">
                <div class="due_empty">
                    <div class="due_img">
                        <img src="/img/00003.png" alt="" />
                    </div>
                </div>
                <p class="due_wrods">目前没有待收货订单</p>
            </div>
            @else
                @foreach($datas as $data)
                    <div class="due_product">
                        <div class="due_title">
                            <div class="due_icon">
                                <img src="/img/00004.png" alt="" />
                                <span>{{ $brands[$data->brand] }}</span>
                                <div class="due_success">待收货</div>
                            </div>
                            <div class="due_code"><span>订单编号：</span>{{ $data->ordernum }}</div>
                        </div>
                        <div class="due_list" onclick="window.location.href='/produc?good_id={{ $data->pro_id }}'">
                            <div class="due_list_l">
                                <img src="{{ env('CDN_DOMAIN_NAME') }}/upload/{{ $data->face }}" alt="" class="due_list_img" />
                            </div>
                            <div class="due_list_r">
                                <div class="due_list_name">
                                    <p class="due_list_tit">{{ $data->title }}</p>
                                    <p class="due_price">￥<b>{{sprintf("%.2f", $data->total_price/$data->num) }}</b></p>
                                </div>
                                <p class="due_list_words">款号：{{ $data->girard }}</p>
                                <div class="due_list_color">
                                    <p class="due_list_hue">颜色：{{ $data->color }}</p>
                                    <p class="due_list_post">邮费：￥{{ sprintf("%.2f",$data->postage_estimate) }} </p>
                                </div>
                                <div class="due_list_b">
                                    @if($data->pre_sale == 1)
                                        <p class="due_list_postage">数量：{{ $data->num }}件</p>
                                        <a href="javascript:;" class="deTa" style="float:left;width:2rem;text-align:end;" abc="{{$data->id}}">详情</a>
                                    @else
                                        <p class="due_list_postage">数量：{{ $data->num }}手</p>
                                    @endif
                                    <p class="due_sum">合计：<i>￥{{sprintf("%.2f", $data->total_price + $data->postage_estimate) }}</i></p>
                                </div>
                            </div>
                        </div>
                        <div class="due_btn">
                            <input type="hidden" class="hiddenBtn" value="">
                            <span class="agency">代理：{{ $companys[$data->form_company_id] }}</span>
                            <a href="javascript:;" class="due_btn_sure del_{{ $data->id }}" abc="{{ $data->id }}">确认收货</a>
                        </div>
                    </div>
                @endforeach
            @endif
            <!--添加-->

        </div>
    </div>
    <div class="delDiv" style="display:none;">
        <div class="delDiv_tip">是否确认收货？</div>
        <div class="delDiv_info">
	            <span id="" class="delDiv_info_left">
	                <input id="btnCancel" class="btnCancel btn-green" type="button" value="取 消" />
	            </span>
	            <span id="" class="delDiv_info_right">
	                <input id="btnDelTrue" class="btnDelTrue btn-green" type="button" value="确 认" />
	            </span>
        </div>
    </div>
    <div class="expurgate" style="display: none;"></div>
    <div class="mask" style="display:none;"></div>

    <div class="pay_mask2 pay_mask" style="display:none;"></div>
    <div class="pay_over" style="display:none;">
        <div class="pay_pass"></div>
        <div class="pay_ok">确定</div>
    </div>
</div>
</body>
<script>
    /*滚动*/
    var myScroll;
    function loaded () {
        setTimeout(function(){
            myScroll = new IScroll('.wrap', {
                mouseWheel: true,
                click: true
            });
        },100);
    }
    document.addEventListener('touchmove', function (e) {e.preventDefault();},false);
    $(".due_btn_sure").click(function(){
        $(".delDiv").show();
        $(".mask").show();
        $(".hiddenBtn").val( $(this).attr("abc") )
    })
    $(".btnDelTrue").click(function(){
        $(".delDiv").hide();
        $(".mask").hide();
        var id=$(".hiddenBtn").val();
        if(id != ''){
            $.ajax({
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf_token"]').attr('content')
                },
                type:'post',
                url:'/user/userTakeGoods',
                data:{
                    'id':id,
                },
                dataType:'json',
                success:function (data) {
                    if(data.success){
                        /*删除该订单*/
                        $(".del_"+id).parent().parent().remove();
                        $(".expurgate").text(data.msg);
                        $(".expurgate").show(0).delay(1000).hide(0);
                    }else{
                        $(".expurgate").text(data.msg);
                        $(".expurgate").show(0).delay(1000).hide(0);
                    }
                }
            });
        }
    })
    /*取消*/
    $(".btnCancel").click(function(){
        $(".delDiv").hide();
        $(".mask").hide();
    })


    $(".deTa").bind('click', function(event) {

//        $(document).on("click",".deTa",function(event){
        event.stopPropagation();
        var id=$(this).attr("abc");
        $.ajax({
            headers: {'X-CSRF-TOKEN': $('meta[name="csrf_token"]').attr('content')},
            url: '/fetch-sale-order-info/'+id,
            data: {},
            type: 'get',
            dataType: 'json',
            success: function (data) {
                if (data.result.success) {
                    $(".pay_pass").empty();
                    var res=data.content;
                    var str='';
                    for(var k in res){
                        str=str+'<p><span>'+res[k].girard+'</span><span>'+res[k].color+'</span><span>'+res[k].size+'码</span><span>'+res[k].num+'件</span></p>';
                    }
                    $(".pay_pass").append(str);
                    $(".pay_over").show();
                    $(".pay_mask2").show();
                } else {
                    $(".faceImg").attr("src", "/img/weep.png");
                    $(".oHandle").text(data.result.errorMsg);
                    $(".oSuccess").show(0).delay(1000).hide(0);
                }
            }
        })

    });
    $(".pay_ok").click(function(){
        $(".pay_over").hide();
        $(".pay_mask2").hide();
    })
</script>
</html>
